<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="/favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet">
	<!-- 搜索样式CSS-Start -->
	<link href="/common/css/searchStyle.css" rel="stylesheet">
	<!-- 搜索样式CSS-End -->
	<!-- 下拉 -->
	<link href="/css/plugins/chosen/chosen.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <!-- Example Events -->
                    <div class="example-wrap">
                        <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                             <form id="seachform">
	                             <div class="seach-context">
											 <label>联系人名称 :</label><input id="name"placeholder="请输入客户名称"/>
											  <label>联系人SMS :</label><input id="sms"placeholder="请输入SMS"/>
											   <label>联系人邮箱:</label><input id="email"placeholder="请输入客户邮箱"/>
											 <label>联系人状态:</label>	
											 <select class="chosen-select" tabindex="8" id="status">
											 </select>
					             </div>
					            <button id="resetBtn" type="button" class="btn btn-w-m btn-white">重置</button>
								<button id="addBtn" type="button"  power="ADDCOMPANYEMPL" class="btn btn-w-m btn-success">新增</button>
								<button id="searchBtn" type="button" class="btn btn-w-m btn-white">查询</button>
								<button id="outline" type="button" class="btn btn-w-m btn-white">导出预警信息</button>
							</form>
                        </div>
                        <table id="systemCompanyEmplTable">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
	<!-- End Panel Other -->
	<script src="/js/jquery.min.js?v=2.1.4"></script>
	<script src="/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="/js/content.min.js?v=1.0.0"></script>
	<script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
	<script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	<script src="/common/petecat.js"></script>
	<script src="/common/bootstrap-table-treetable.js"></script>
	<script src="/common/bootstrap-table.js"></script>
	<script src="/common/form.js"></script>
	<!-- HTML之间的传值 -->
	<script src="/js/jquery.params.js"></script>
	<script src="/js/plugins/layer-pc/layer.js"></script>
	<script src="/js/jquery.cookie.js"></script>
    <!-- 组件通用 -->
    <script src="/common/frame.js"></script>
    <!-- 下拉 -->
	<script src="/js/plugins/chosen/chosen.jquery.js"></script>
<script type="text/javascript">
checkPowerAndJump("QRYCOMPANYEMPL");
    $(function(){
    	//导出预警人员信息到Execl
		$("#outline").click(function(){
			window.location.href=BASE_URL+'/base/warningempl/outOpenRuleEmplInfo';
		});
		
    	
    	var status =JSON.parse('[{"key":"","value":"全部"},{"key":"0","value":"禁用"},{"key":"1","value":"启用"}]');
    	var item = {
    		id:"status",
    		data:status
    	};
    	initSelectData(item);
    	$('#resetBtn').click(function(){
    		$('#seachform').resetForm();
    	});
        $('#addBtn').click(function(){
            winLayerIndex = layer.open({
                type: 2,
                title: '新增公司联系人',
                shade: 0.8,
                area: ['380px', '50%'],
                content: ['/system/companyempl/add.html', 'auto'], 
                end: function(){ //此处用于演示
                    refreshGrid('systemCompanyEmplTable');
                },
                success:function(){
                }
            });
        });
        $('#searchBtn').click(function(){
            refreshGrid('systemCompanyEmplTable');
        });
        var table = {};
    	table['id'] = 'systemCompanyEmplTable';
    	table['url'] = SSO_URL+'/system/companyempl/queryCompanyEmplByPage',
    	table['pagination'] = true,
    	table['queryParams'] = function(){
    		var queryParams = {};
    		queryParams['sms'] = $('#sms').val();
            queryParams['email'] = $('#email').val();
            queryParams['name'] = $('#name').val();
            queryParams['status'] = $('#status').val();
            return queryParams;
    	};
    	table['columns'] = [{
	    	 field:'name',
	         title:'联系人名称'
		    },{
	    	 field:'sms',
	         title:'SMS'
		    },{
	    	 field:'email',
	         title:'联系人邮箱'
	    	},{
            field:'status',
            title:'联系人状态',
            formatter:function(value,row,index){
            	return row['status']==0?"禁用":"启用";
            }
        },{
        	field : "opt",
        	title:"操作",
        	width: 200,
        	formatter: function(value, row, index) {
        		 var html = "";
        		 var state = row['status']== 0 ?"启用":"禁用";
        		 if(row['status'] == 1){
        			 if(checkPower("UPDCOMPANYEMPL")){
	       				 html+='<a class="edit" href="javascript:void(0)" title="修改">修改</a>&nbsp;&nbsp;&nbsp;';
	       		     }
        		 }
        		 if(checkPower("DELCOMPANYEMPL")){
					 html+= '<a class="del" href="javascript:void(0)" title="'+state+'">'+state+'</a>&nbsp;&nbsp;&nbsp;';
				 }
				 return html;
        	},
            events:{
                'click .edit':function(e, value, row, index){
                	updWinLayerIndex = layer.open({
                        type: 2,
                        title: '修改公司信息',
                        shade: 0.8,
                        area: ['380px', '50%'],
                        content: ['/system/companyempl/edit.html', 'auto'], //iframe的url，no代表不显示滚动条
                        end: function(){ //此处用于演示
                            refreshGrid('systemCompanyEmplTable');
                        },
                        success:function(layers,index){
                            var body = layer.getChildFrame('body', index);
                            var FormOptions = {};
                            FormOptions['jsonValue'] = row;
                            FormOptions['isDebug'] = true;
                            body.find('#signupForm').initForm(FormOptions);
                        }
                    });
                },
        		'click .del':function(e, value, row, index){
        			var text = '';
        			var state = row['status'];
        			if(state == 0){
        				text = '启用';
        				state = '1';
        			}else{
        				text = '禁用';
        				state = '0';
        			}
        			layer.confirm('是否'+text+'当前公司', {
      					btn: ['是','否'] //按钮
       				}, function(){
    		        	var req = {};
    		        	req['reqJSON'] = {
    	        			type : 'delete',
    	        			url : SSO_URL+'/system/companyempl/removeCompanyEmplById?companyEmplId='+row.id+'&state='+state
    		        	};
    		        	req['successFn'] = function(respData){
    		        		layer.msg(respData.message, {icon: 6},function(){
            				}); 
    		        		if(respData.code == SUCCESS_CODE){
    		        			refreshGrid('systemCompanyEmplTable');
        					}
    		        	};
    		        	ajaxRequest(req);
       				});
        		}
            }
        }];
    	initTable(table);
    });
</script>
</body>
</html>